package charlie.demo.bus1.action;

import act.db.beetlsql.BeetlSqlTransactional;
import act.util.Output;
import act.validation.NotBlank;
import charlie.demo.bus1.entity.DemoEntity;
import charlie.demo.bus1.entity.User;
import charlie.demo.bus1.service.Bus1Service;
import charlie.demo.bus1.service.MyService;
import charlie.demo.bus1.service.SystemMapper;
import org.beetl.sql.core.SQLManager;
import org.osgl.http.H;
import org.osgl.inject.annotation.RequestScoped;
import org.osgl.mvc.annotation.GetAction;
import org.osgl.mvc.annotation.PostAction;
import org.osgl.mvc.annotation.With;

import javax.inject.Inject;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@With(BeetlSqlTransactional.class)
public class Bus1Action {

    @Inject
    private MyService dbService;

    @Inject
    private Bus1Service bus1Service;

    @Inject
    private SystemMapper mapper;

    @Inject
    private SQLManager sqlManager;

    @GetAction("/bus1")
    public Object bus1(@NotBlank String userName, DemoEntity entity){
        int first = mapper.queryFirst();
        List<Map> list = mapper.querySecond();

        int i = sqlManager.selectSingle("system-man.system.queryFirst", null, Integer.class);
        //bus1Service.crud();
        //return dbService.singleInt("system-man.system.queryFirst");
        return list.size() +":" + i + ":" + first;
    }
    @PostAction("/bus2")
    public Object bus2( String userName, @NotBlank DemoEntity entity){
        return "Okay";
    }
}
